<script setup>
import * as echarts from 'echarts';
import { onMounted, ref } from 'vue';

onMounted(() => {
  genderPie()
  postgraduatePie()
})
const genderPie = () => {
  let chartDom = document.getElementById('genderPie');
  let myChart = echarts.init(chartDom);
  let option;

  option = {
    title: {
      text: '用户男女比例',
      left: 'center'
    },
    tooltip: {
      trigger: 'item',
      formatter: '{d}%'
    },
    legend: {
      top: '10%',
      left: 'center'
    },
    series: [
      {
        top: '10%',
        name: 'Access From',
        type: 'pie',
        radius: ['40%', '70%'],
        avoidLabelOverlap: false,
        padAngle: 5,
        itemStyle: {
          borderRadius: 10
        },
        label: {
          show: false,
          position: 'center'
        },
        emphasis: {
          label: {
            show: true,
            fontSize: 40,
            fontWeight: 'bold'
          }
        },
        labelLine: {
          show: false
        },
        data: [
          { value: 558, name: '男' },
          { value: 735, name: '女' }
        ]
      }
    ]
  };

  option && myChart.setOption(option);
}
const postgraduatePie = () => {
  let chartDom = document.getElementById('postgraduatePie');
  let myChart = echarts.init(chartDom);
  let option;

  option = {
    title: {
      text: '用户男女比例',
      left: 'center'
    },
    tooltip: {
      trigger: 'item',
      formatter: '{d}%'
    },
    legend: {
      top: '10%',
      left: 'center'
    },
    series: [
      {
        top: '10%',
        name: 'Access From',
        type: 'pie',
        radius: ['40%', '70%'],
        avoidLabelOverlap: false,
        padAngle: 5,
        itemStyle: {
          borderRadius: 10
        },
        label: {
          show: false,
          position: 'center'
        },
        emphasis: {
          label: {
            show: true,
            fontSize: 40,
            fontWeight: 'bold'
          }
        },
        labelLine: {
          show: false
        },
        data: [
          { value: 558, name: '男' },
          { value: 735, name: '女' }
        ]
      }
    ]
  };

  option && myChart.setOption(option);
}
</script>

<template>
  <div style="display: flex;overflow: hidden;">
    <el-card class="animate__animated animate__bounceInLeft" style="width:50%;height: 600px; margin-right: 2%;">
      <div id="genderPie" style="width: 100%; height: 600px">

      </div>
    </el-card>
    <el-card class="animate__animated animate__bounceInRight" style="width:50%;height: 600px;margin-right: 2%;">
      <div id="postgraduatePie" style="width: 100%;height: 600px">

      </div>
    </el-card>
  </div>
</template>

<style scoped></style>
